package main;

import java.io.IOException;
import java.util.ArrayList;

import utils.FileHelper;

@SuppressWarnings("all")
public class Main {
	private static int counter = 0;
	//defines the number of available processors
	private static int m = 3 ;
	//defines the size of systems that should be considered
	public static int system_size = 4;
	//print result
	private static boolean print = false;
	
	private static void schedule(String p){
		Program pgm = new Program(m, p);
	
		if(pgm.run())
			counter++;
		if (print)
			pgm.print();
	
	}
	
	//take all the systems in a specified folder -> see utils.FileHelper
	private static void all_systems(){
		try {
			
			ArrayList<String> paths = FileHelper.getInstance().all_system_paths();
			for (String p : paths){
				//remove the absolute path and keep only the file name
				p = p.replaceAll("/Users/Vinh/Workspaces/Eclipse/Scheduler/Tasks/", "");
				System.out.println(p);
				schedule(p);
				System.out.println("Number of systems" +counter);
			}
		
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	
	//get all the systems through a loop
	private static void all_systems2(){
			
			for(int i=1; i<= 5000; i++){
				String path = "set"+i;
					System.out.println(path);
				schedule(path);
					System.out.println("Number of systems" +counter);

			}
	}
	public static void main(String[] args)  {
		//launch the program on a certain file
//		schedule("set306");
		//launch the program on all the files from the folder "Tasks"
//		all_systems();
		all_systems2();
	}

}
